﻿<UserControl x:Class="Squiggle.UI.Controls.SignInControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:controls="clr-namespace:Squiggle.UI.Controls"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:converters="clr-namespace:Squiggle.UI.Converters"
    Loaded="UserControl_Loaded">
    
    <UserControl.Resources>
        <LinearGradientBrush x:Key="SignedOffBackground1" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FF3DB3EA" Offset="0.012"/>
            <GradientStop Color="#FFE4F1F7" Offset="0.116"/>
            <GradientStop Color="White" Offset="0.23"/>
            <GradientStop Color="White" Offset="0.738"/>
            <GradientStop Color="#FFD0EAF5" Offset="0.953"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="SignedOffBackground2" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFFCFCFC" Offset="0.022"/>
            <GradientStop Color="#FFEEEEEA" Offset="0.207"/>
            <GradientStop Color="#FFEEE6E6" Offset="0.164"/>
            <GradientStop Color="#FFF0F0F0" Offset="0.983"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="SignedOffBackground" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFFCFCFC" Offset="0.022"/>
            <GradientStop Color="#FFECECF4" Offset="0.461"/>
            <GradientStop Color="#FFE6E7EE" Offset="0.397"/>
            <GradientStop Color="#FFF0F0F0" Offset="0.983"/>
        </LinearGradientBrush>
        <BooleanToVisibilityConverter x:Key="visibilityConverter" />
        <converters:SingleSignOnToVisibilityConverter x:Key="SSOvisibilityConverter" />
    </UserControl.Resources>
    <Grid Background="{StaticResource SignedOffBackground}">        
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>            
            <Image HorizontalAlignment="Center" Margin="0,30,0,0" Source="..\Images\contacts.png" Height="128" Width="128"/>                        
            <StackPanel Grid.Row="1" Orientation="Vertical">
                <TextBlock Text="{DynamicResource MainWindow_SignIn_SignIn}"  FontSize="18" Foreground="#FF355A88" HorizontalAlignment="Center"/>
                <Border CornerRadius="5" BorderBrush="#FFD8E8F0" BorderThickness="1" Margin="10">
                    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5">
                        <StackPanel x:Name="lblSingleSignOn" Visibility="{Binding SingleSignOn, Converter={StaticResource visibilityConverter}}">
                            <TextBlock Text="{DynamicResource MainWindow_SignIn_SingleSignOn}" HorizontalAlignment="Center" ></TextBlock>
                        </StackPanel>
                        <StackPanel Visibility="{Binding AskDisplayName, Converter={StaticResource visibilityConverter}}">
                            <TextBlock Text="{DynamicResource MainWindow_SignIn_DisplayName}" TextWrapping="Wrap" />
                            <TextBox x:Name="txtDisplayName" Margin="5,10,5,0" Text="{Binding DisplayName, UpdateSourceTrigger=PropertyChanged}" MaxLength="50" BorderBrush="{x:Null}" />
                        </StackPanel>
                        <StackPanel Visibility="{Binding AskUsername, Converter={StaticResource visibilityConverter}}">
                            <TextBlock Text="{DynamicResource MainWindow_SignIn_Username}" TextWrapping="Wrap" />
                            <TextBox Margin="5,10,5,0" Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}" MaxLength="50" BorderBrush="{x:Null}" />
                        </StackPanel>
                        <StackPanel Visibility="{Binding AskDomain, Converter={StaticResource visibilityConverter}}">
                            <TextBlock Text="{DynamicResource MainWindow_SignIn_Domain}" TextWrapping="Wrap" />
                            <TextBox Margin="5,10,5,0" Text="{Binding Domain, UpdateSourceTrigger=PropertyChanged}" MaxLength="50" BorderBrush="{x:Null}" />
                        </StackPanel>
                        <StackPanel Visibility="{Binding AskPassword, Converter={StaticResource visibilityConverter}}">
                            <TextBlock Text="{DynamicResource MainWindow_SignIn_Password}" TextWrapping="Wrap" />
                            <PasswordBox Margin="5,10,5,0" x:Name="txtPassword" MaxLength="50" BorderBrush="{x:Null}" />
                        </StackPanel>
                        <StackPanel Visibility="{Binding AskGroupName, Converter={StaticResource visibilityConverter}}">
                            <TextBlock Margin="0,5,0,0" Text="{DynamicResource MainWindow_SignIn_GroupName}" TextWrapping="Wrap" />
                            <ComboBox Margin="5,10,5,0" x:Name="txtGroupName" Text="{Binding GroupName, UpdateSourceTrigger=PropertyChanged}"
                                  IsEditable="True" controls:EditableComboBox.MaxLength="25"
                                  PreviewKeyDown="txtGroupName_PreviewKeyDown" DisplayMemberPath="GroupName" 
                                  SelectedValuePath="GroupName" />
                        </StackPanel>
                        <CheckBox IsChecked="{Binding RememberMe}" Margin="5,10,0,0" Content="{DynamicResource MainWindow_SignIn_RememberMe}" HorizontalAlignment="Left" Visibility="{Binding SingleSignOn, Converter={StaticResource SSOvisibilityConverter}}"/>
                        <CheckBox IsChecked="{Binding AutoSignIn}" Margin="5,10,0,5" Content="{DynamicResource MainWindow_SignIn_AutoSignIn}" HorizontalAlignment="Left" Visibility="{Binding SingleSignOn, Converter={StaticResource SSOvisibilityConverter}}"/>
                    </StackPanel>
                </Border>
                <Button HorizontalAlignment="Center" IsDefault="True" Width="60" Height="25" Content="{DynamicResource MainWindow_SignIn_SignInButton}" Click="SignIn"
                        Template="{DynamicResource BlueGlassButton}" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
